﻿using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour {
	public const int MAXUNITS=200;
	public int gold;
	public int attackUpgrade=0, atkSpeedUpgrade=0, speedUpgrade=0, lifeUpgrade=0;
	public Unit commandCenter;
	public Color myColor;
	public Group spawnGroup=new Group();
	public static Player Controller;
	ArrayList units;
	ArrayList selectedUnits;
	public Player(){
		units= new ArrayList(MAXUNITS);
		selectedUnits=new ArrayList();
	}
	public void clearSelection(){
		foreach(Unit u in selectedUnits)
			u.displaySelection(false);
		selectedUnits.Clear();
	}
	public bool canCreateUnit(Unit u){
		return units.Count<MAXUNITS;	
	}
	public int getPopLeft(){
		return MAXUNITS-units.Count;	
	}
	public void addUnit(Unit u){
		foreach(Renderer o in u.gameObject.GetComponentsInChildren<Renderer>())
		{
				o.material.color=this.myColor;
		}
			//obj.renderer.material.color= myColor;
		units.Add(u);
	}
	public ArrayList getSelectedUnits(){
		return selectedUnits;	
	}
	public void setSelectedUnits(ArrayList newunits){
		selectedUnits=newunits;
	}
	public ArrayList getUnits(){
		return units;
	}
	
}
